#!/usr/bin/python
from itertools import chain
s = '2001:db8:4:5::1'
import string
if s.find('::') > 0:
    s1, s3 = (''.join([i.zfill(4) for i in part.split(':')]) for part in s.split('::'))
    print s1,s3
    s2 = ''.join(['0' for _ in range(32 - len(s1) - len(s3))])
#   lst1[1:1] = lst2
    print '.'.join([i for j in [s1, s2, s3] for i in j])


else:
    print '.'.join(list(''.join([part.zfill(4) for part in s.split(':')])))
    print '.'.join([i for part in s.split(':') for i in part.zfill(4)])[::-1]
   #print list(chain(list(part.zfill(4)) for part in s.split(':')))
